package com.Drools.CIPS.controller;

import com.Drools.CIPS.bean.Rulers;
import com.Drools.CIPS.ruler.MTRuler;
import com.Drools.CIPS.sercice.DroolsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RequestMapping("/drools")
@RestController
public class getController {
    @Resource
    DroolsService droolsService;

    @GetMapping("/AllDrools")//所有规则
    public List<Rulers> AllDrools(){
        List<Rulers> list = droolsService.getAll();
        System.out.println(list);
        return list;
    }
    @GetMapping("/goodDrools")//好的规则
    public List<Rulers> goodDrools(){
        List<Rulers> l = droolsService.getGood();
        System.out.println(l);
        return l;
    }
    @GetMapping("/useDrools")//使用的规则
    public Map<String,List<String>> useDrools(){
        Map<String,List<String>> m = MTRuler.getRulers();
        System.out.println(m);
        return m;
    }
    @GetMapping("/use")//使用全部规则
    public String use(){
        Map<String,Object> map = new HashMap<>();
        map.put("a","a");
        Integer m = MTRuler.use(map,"");
        System.out.println(m);
        return "触发了" + m +"条规则";
    }
    @GetMapping("/useGroup")//使用全部规则
    public String useGroup(String allGroup){
        Map<String,Object> map = new HashMap<>();
        map.put("a","a");

        Integer m = MTRuler.useGroup(map,allGroup);
        System.out.println(m);
        return "触发了" + m +"条规则";
    }

}
